package cource.FinalExam;

import org.junit.Test;

import java.io.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;

/**
 * @author zeng
 * @data 2021/05/16 15:41
 */
public class ThreadFile {
    @Test
    public void CreateFile(){
        File file = new File("E:\\资料\\2.txt");
        try {
            System.out.println(file.createNewFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    //实现从文件中读取数据排序然后写入
    public static void main(String[] args) {
//        String s1="2009-02-06 18:00:00";
//        String s2="2009-02-06 18:30:00";
//        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
//        try {
//            System.out.println((format.parse(s2).getTime() - format.parse(s1).getTime()) / 60000);
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
        File file = new File("");
        if(file.isFile()){
            System.out.println(1);
        }

//        //读取文件
//        BufferedReader bf = null;
//        //创建一个列表，存储数据
////        List list = new ArrayList<Integer>();
//        HashSet<Integer> list = new HashSet<>();
//        try {
//            bf = new BufferedReader(new FileReader(new File("D:\\Googl浏览器下载\\largeAllowlist.txt")));
//            String str = null;
//            try {
//                Date starttime = new Date();
//                //开始时间
//                String starttimefromat = new SimpleDateFormat("HH:mm:ss").format(starttime);
//                //当读取到最后一行结束, 已经读取一行
//                while ((str = bf.readLine()) != null){
//                    list.add(Integer.parseInt(str.replaceAll("\\s*", "")));
//                }
//                if(bf != null){
//                    bf.close();
//                }
//                //数组长度
//                Integer[] arr = new Integer[list.size()];
//                list.toArray(arr);
//                //排序
//                Arrays.sort(arr);
////                System.out.println(Arrays.toString(arr));
//                //结束时间
//                Date endTime = new Date();
//                String endTimefromat = new SimpleDateFormat("HH:mm:ss").format(endTime);
//                System.out.println(starttimefromat + "-" + endTimefromat);
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        } catch (FileNotFoundException e) {
//            e.printStackTrace();
//        }
//        OrderSeekThread t1 = new OrderSeekThread("D:\\Googl浏览器下载\\largeText.txt", 199694);
////        BinarySeekThread t2 = new BinarySeekThread("D:\\Googl浏览器下载\\largeText.txt", 199694);
//////        t1.start();
////        t2.start();
//////        System.out.println("t1:" + t1.flag);
////        System.out.println("t2:" + t2.flag);
////        while(true){
//////            if(t1.getState() == Thread.State.TERMINATED){
//////                System.out.println(t1.starttime + "-" + t1.endtime);
//////                System.out.println("t1:" + t1.flag);
//////                break;
//////            }
////            if(t2.getState() == Thread.State.TERMINATED){
////                System.out.println(t2.starttime + "-" + t2.endtime);
////                System.out.println("t2:" + t2.flag);
////                break;
////            }
////        }
    }
}
